import React, { Component } from 'react'

export default class RefCom extends Component {
  toDiv=()=>{
    this.div.innerHTML=this.input.value
  }
  toDivs=(e)=>{
    // console.log(e.keyCode);
    if (e.keyCode===13) {
    this.div.innerHTML=this.input.value 
    }
    
  }
  render() {
    return (
      <div>
        <input ref={el=>this.input=el} onKeyUp={this.toDivs} type="text" name="" id="" />
        <button onClick={this.toDiv} >发送</button>
        <hr />
        <div ref={el=>this.div=el} style={{width:400,height:300,border:'1px solid black'}}></div>
      </div>
    )
  }
}
